package twentytwenty;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2020-12-16 16:13
 * @Modified By:
 */
public class HammingDistance_461 {
    public static void main(String [] args){

    }

    public static int hammingDistance(int x,int y){
        int result = x ^ y;
        int count = 0;
        String s = Integer.toBinaryString(result);
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1'){
                count++;
            }
        }
        return count;
    }
}
